package com.spring.applicationEven_annotation_demo;


import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


public class BlackListNotifier {

	private String notificationAddress;

	public void setNotificationAddress(String notificationAddress) {
		this.notificationAddress = notificationAddress;
	}

	@EventListener
	public void processBlackListEvent(BlackListEvent event) {
		// notify appropriate parties via notificationAddress...
		System.out.println(event.getAddress());
		System.out.println(event.getContent());
	}

	@EventListener
	@Async//异步
	public void processSecondEvent(SecondEvent event) {
		// notify appropriate parties via notificationAddress...
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(event.getName());
		System.out.println(event.getMsg());

	}
}